// Domain/Repositories/IOperationLogRepository.cs
using UniversalAdmin.Domain.Entities;

namespace UniversalAdmin.Domain.Repositories;

public interface IOperationLogRepository : IRepository<OperationLog>
{
  // 日志查询
  Task<IEnumerable<OperationLog>> GetLogsByUserIdAsync(int userId);
  Task<IEnumerable<OperationLog>> GetLogsByResourceAsync(string resource, int? resourceId = null);

  // 高级查询
  Task<(IEnumerable<OperationLog> Items, int TotalCount)> SearchLogsAsync(
      string? action = null,
      string? resource = null,
      int? resourceId = null,
      int? userId = null,
      DateTime? startDate = null,
      DateTime? endDate = null,
      int pageIndex = 1,
      int pageSize = 10);

  Task<(IEnumerable<OperationLog> Items, int TotalCount)> SearchWithUserAsync(
    string? username,
    string? action,
    string? resource,
    DateTime? startDate,
    DateTime? endDate,
    int pageIndex = 1,
    int pageSize = 10);

  // 日志清理
  Task<int> CleanOldLogsAsync(DateTime cutoffDate);
}